home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / win_nt95 / cm95-10.zip / ONTV.OZ < prev    next >
Text File  |  1996-10-29  |  7KB  |  217 lines

  1. ;Gets a summary of tonight's network TV offerings.
  2. ;This article from United Features is updated every day except Sunday,
  3. ;shortly after Noon Eastern Time (9am Pacific).
  4.  
  5. ;****************************************************************************
  6. ; ClockMan95 Automation Assistant support file
  7. ; (c) 1995 Graphical Dynamics, Inc. The "Common helper functions" are placed
  8. ; in the public domain; otherwise permission is granted to use/modify this
  9. ; script file as long as it's not for resale.
  10. ;
  11. ; Written by: Jennifer Palonus
  12. ;
  13. ; Date    Who   Major changes
  14. ;-------  ---   -------------------------------------------------------------
  15. ;16aug95  jlp   Created.
  16. ;****************************************************************************
  17.         define $ServiceName             ; used by GoService
  18.         define #ServiceHasHdr   ; used by GoService
  19.         define $MenuItem                ; used by ChooseMenuItem & FindMenuItem
  20.         define $SubjectLine             ; used by CaptureMsg
  21.         define $Prompt                  ; used by WaitForPrompt
  22.         define #OK                              ; used everywhere. Routines return %TRUE or /%FALSE
  23.         onerror HandleErrors
  24.         timeout 90
  25.  
  26.  
  27. ;****************************************************************************
  28. ; Main processing section.
  29. ;****************************************************************************
  30.         set $ServiceName    "CIS:SYN-23"
  31.         set #ServiceHasHdr  %FALSE
  32.         set $Prompt         ^M^J "!"
  33.         gosub GoService
  34.  
  35.         set $MenuItem       "Tune In Tonight"
  36.         gosub FindMenuItem
  37.         if #OK = %FALSE fail
  38.  
  39.         set $MenuItem       "1"
  40.         gosub ChooseMenuItem
  41.  
  42.         set $SubjectLine    "'Tune in Tonight'"
  43.         gosub CaptureMsg
  44.         end
  45.  
  46.  
  47. ;****************************************************************************
  48. ; Common helper functions. (These are placed in the "public domain" by GDI.)
  49. ;****************************************************************************
  50. ; GoService
  51. ;
  52. ; Carries out a GO command & passes over the introductory text (if any).
  53. ; When this returns, you're ready to capture or parse the service's top menu.
  54. ;
  55. ; $ServiceName        The CIS service you want to GO to.
  56. ; #ServiceHasHdr    Does this service have an intro paragraph ending with a
  57. ;                    "MORE !" prompt?
  58. ;****************************************************************************
  59. GoService:
  60.     set #OK %TRUE
  61.     sendln "GO " $ServiceName
  62.  
  63.     if #ServiceHasHdr = %FALSE return
  64.     set $Prompt ^M^J "MORE !"         
  65.     gosub WaitForPrompt
  66.     send %CR
  67.     return
  68.  
  69.     
  70. ;****************************************************************************
  71. ; ChooseMenuItem
  72. ;
  73. ; Selects an article (by item #) from a menu. Upon return, you're ready to
  74. ; CaptureMsg it.
  75. ;
  76. ; $MenuItem            The menu selection #.
  77. ; $SubjectLine        The generated mail message's subject line if different
  78. ;                    than the default.
  79. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  80. ;****************************************************************************
  81. ChooseMenuItem:
  82.     set #OK %TRUE
  83.     set $Prompt ^M^J "!"
  84.     gosub WaitForPrompt
  85.  
  86.     sendln $MenuItem
  87.     wait ^M^J            ; Skip echo of menu item #
  88.     return
  89.  
  90.  
  91. ;****************************************************************************
  92. ; FindMenuItem
  93. ;
  94. ; Selects the first item in a menu that contains the string in $MenuItem.
  95. ; Assumes the menu is being sent & ready to parse.
  96. ;
  97. ; This is for services that keep adding articles to the front of the menu,
  98. ; and the article we're looking for always has the same title. There can end
  99. ; up being 0, 1, or more items with the same name, in unpredictable positions
  100. ; in the menu. The 1st one we find (lowest item #) is the most recent one.
  101. ; (ex.: AP's "Today in History", or "<day>'s Most Active Stocks", etc.)
  102. ;
  103. ; Using this routine also protects you when the provider moves items around
  104. ; within a menu. (It doesn't protect against the provider changing menu
  105. ; item names or moving items to other menus.)
  106. ;
  107. ; Upon return, #OK is %TRUE or %FALSE depending on whether any items were
  108. ; found that contained $MenuItem. If %TRUE then $MenuItem is also set to the
  109. ; full menu item description & caller is ready to capture or parse the
  110. ; selected article/submenu.
  111. ;
  112. ; If $MenuItem is found in the preface to the menu, then I guess we could get
  113. ; into trouble!
  114. ;
  115. ; $MenuItem            The menu selection name (or partial name).
  116. ; $SubjectLine        The generated mail message's subject line if different
  117. ;                    than the default.
  118. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  119. ;****************************************************************************
  120. FindMenuItem:
  121.     define $FMILine
  122.     define $FMIItem
  123.     define $FMINum
  124.     define #FMIToken
  125.     define #FMIFound
  126.  
  127.     set #OK %TRUE
  128.     FMILoop:
  129.         add 1 "!"
  130.         add 2 ^M^J                ; Examine each line in turn...
  131.         mwait #FMIToken
  132.         
  133.         if #FMIToken = 2 goto FMICheckWholeLine
  134.  
  135.         ; ...else this is either a "!" or "MORE !" prompt, or a
  136.         ; stray "!" or "MORE !" inside a whole line...
  137.         set $FMILine %COMDATA
  138.         trim $FMILine
  139.  
  140.         ; If multipart menu, tell CIS to send next part...
  141.         if $FMILine = "MORE !" send %CR
  142.         if $FMILine = "MORE !" goto FMILoop
  143.  
  144.         ; If end of full menu & item wasn't found...
  145.         if $FMILine = "!" set #OK %FALSE
  146.         if $FMILine = "!" return
  147.  
  148.         FMICheckWholeLine:
  149.         set $FMILine %LCOMDATA
  150.         
  151.         ; Split off what should be item description & check it...
  152.         midstr $FMILine 4 255 $FMIItem
  153.         posnc #FMIFound $MenuItem $FMIItem
  154.     if #FMIFound = 0 goto FMILoop
  155.     
  156.     ; If we get here, we've found $MenuItem in a line...
  157.     midstr $FMILine 1 2 $FMINum
  158.     trim $FMINum        ; We ASSUME first nonblank chars are a real menu item #!
  159.  
  160.     ; Now that we have our item, skip the rest of the menu...
  161.     set $Prompt ^M^J "!"
  162.     gosub WaitForPrompt
  163.     sendln $FMINum
  164.     wait ^M^J                    ; Skip echo of menu item #
  165.     set $MenuItem $FMIItem        ; Return full menu item description
  166.     return
  167.  
  168.  
  169. ;****************************************************************************
  170. ; CaptureMsg
  171. ;
  172. ; Assuming CIS is about to send us the text that we want to place into a mail
  173. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  174. ;
  175. ; $SubjectLine        The custom subject line if different than the default.
  176. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  177. ;****************************************************************************
  178. CaptureMsg:
  179.     set #OK %TRUE
  180.     capture on CISMAIL.MSG
  181.     if $SubjectLine =  "" WMH
  182.     if $SubjectLine <> "" WMH $SubjectLine
  183.  
  184.     gosub WaitForPrompt
  185.     capture off
  186.  
  187.     set $SubjectLine ""
  188.     return
  189.  
  190.  
  191. ;****************************************************************************
  192. ; WaitForPrompt
  193. ;
  194. ; Wait till the end of a menu or opening text. This routine handles menus
  195. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  196. ; If you DO want to wait for "MORE !", then set $Prompt to it.
  197. ;
  198. ; $Prompt            The prompt you're waiting for. Usu. ^M^J "!".
  199. ;****************************************************************************
  200. WaitForPrompt:
  201.     define #WFPToken
  202.     set #OK %TRUE
  203.     
  204.     add 1 $Prompt
  205.     add 2 ^M^J "MORE !"
  206.     mwait #WFPToken
  207.     if #WFPToken = 2 send %CR
  208.     if #WFPToken = 2 goto WaitForPrompt
  209.  
  210.     return
  211.  
  212.  
  213. ;****************************************************************************
  214. HandleErrors:
  215.     fail
  216.  
  217.